<?php

namespace App\Http\Controllers\Backend;

use App\Repositories\FormValueRepository;
use Carbon\Carbon;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\DB;
use Raindance\RainAdmin\Services\ResponseUtil;

class DashboardController extends Controller
{
    private $repo;
    public function __construct(FormValueRepository $repo)
    {
        $this->middleware(['web', 'admin']);
        $this->repo = $repo;
    }

    public function index(){
//        $danger = DB::connection('oracle')->table('SAFE_HAZA_CHECKLIST')->get()->toArray();
//        dump($danger);
        return view('backend.dashboard.index');
    }

    public function getCount(){
        $now = Carbon::today();
        $start = $now->startOfWeek()->toDateString();
        $end= $now->endOfWeek()->toDateString();
        $data = [];
        $data['hidden'] = $this->getFormValueByWeekCount($start,$end,1);
        $data['danger'] = $this->getFormValueByWeekCount($start,$end,2);
        $data['workforce'] = $this->getWorkforceCountByDay($now);
        return ResponseUtil::success($data);
    }
}
